// Class defining a status bar
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.BorderFactory;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.CompoundBorder;
import java.awt.Color;
import java.awt.Font;
import java.awt.FlowLayout;
import java.awt.Dimension;
import static Constants.GTextbookConstants.*;
import javax.swing.Box;

public class StatusBar extends JPanel {
  // Constructor
  public StatusBar() {
    setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5));    
    //setBackground(Color.LIGHT_GRAY);
    //setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    setBorder(new CompoundBorder(
           BorderFactory.createLineBorder(Color.black, 1),         // Outer border
           BorderFactory.createBevelBorder(BevelBorder.RAISED))); 
    add(typePane);
    add(namePane);
    add(Box.createHorizontalStrut(10)); 
    add(deriveNumPane);
    add(generateNumPane);                           
    add(axiNumPane);
    add(defNumPane);
    add(theNumPane);   
    add(formNumPane); 
                                 
  }

  // Set color pane label
  public void setNamePane(String name) {
    namePane.setText(name);
    namePane.setFont(Status_Font);
    namePane.setPreferredSize(new Dimension(200,20));              
  }
  public void setNamePane() {
    namePane.setText(null);                     
  }
  public void setTypePane (int type) { 
    if(type == Definition)
       typePane.setText("Definition");
       typePane.setFont(Status_Font);
       typePane.setPreferredSize(new Dimension(100,20));                       // Set the pane text
    if(type == Theorem)
       typePane.setText("Theorem"); 
  }
  public void setTypePane (){
     typePane.setText(null);
  }
  
  public void setDefNumPane(int defNum){
     defNumPane.setText("Def. Num. " + (defNum + 10));
     defNumPane.setFont(Status_Font);
     defNumPane.setPreferredSize(new Dimension(100,20)); 
  }
  public void setTheNumPane(int theNum){
     theNumPane.setText("Thm. Num. " + (theNum+10));
     theNumPane.setFont(Status_Font);
     theNumPane.setPreferredSize(new Dimension(100,20)); 
  }
  public void setAxiNumPane(int theNum){
     axiNumPane.setText("Axi. Num. " + theNum);
     axiNumPane.setFont(Status_Font);
     axiNumPane.setPreferredSize(new Dimension(100,20)); 
  }
  public void setAxiNumPane(){
     axiNumPane.setText("Axi. Num. ");
     axiNumPane.setFont(Status_Font);
     axiNumPane.setPreferredSize(new Dimension(100,20)); 
  }
  public void setFormNumPane(int theNum){
     formNumPane.setText("For. Num. " + theNum);
     formNumPane.setFont(Status_Font);
     formNumPane.setPreferredSize(new Dimension(100,20)); 
  }
  public void setFormNumPane(){
     formNumPane.setText("For. Num. ");
     formNumPane.setFont(Status_Font);
     formNumPane.setPreferredSize(new Dimension(100,20)); 
  }
  public void setDeriveNumPane(){
     deriveNumPane.setText("Derive ");
     deriveNumPane.setFont(Status_Font);
     deriveNumPane.setPreferredSize(new Dimension(100,20));
  }
    public void setDeriveNumPane(int theNum){
     deriveNumPane.setText("Derive " + theNum);
     deriveNumPane.setFont(Status_Font);
     deriveNumPane.setPreferredSize(new Dimension(100,20)); 
  }
    public void setGenerateNumPane(){
     generateNumPane.setText("Gener ");
     generateNumPane.setFont(Status_Font);
     generateNumPane.setPreferredSize(new Dimension(100,20));
  }
    public void setGenerateNumPane(int theNum){
     generateNumPane.setText("Gener " + theNum);
     generateNumPane.setFont(Status_Font);
     generateNumPane.setPreferredSize(new Dimension(100,20)); 
  }
  
  

  // Panes in the status bar
  private StatusPane namePane = new StatusPane();
  private StatusPane typePane = new StatusPane();
  private StatusPane defNumPane = new StatusPane();
  private StatusPane theNumPane = new StatusPane();
  private StatusPane axiNumPane = new StatusPane();
  private StatusPane formNumPane = new StatusPane();  
  private StatusPane deriveNumPane = new StatusPane();
  private StatusPane generateNumPane = new StatusPane();
  // Class defining a status bar pane
  class StatusPane extends JLabel {
    public StatusPane() {
      setBackground(Color.LIGHT_GRAY);      // Set background color
      setForeground(Color.BLACK);                   // Set the fixed font
      setHorizontalAlignment(CENTER);      // Center the pane text 
      setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
      setPreferredSize(new Dimension(100,20));                      // Set the text in the pane
    }
  }
}
